using UnityEngine;

public class ArrowScript : MonoBehaviour
{
	public float moveSpeed;

	public Rigidbody2D rg2d;

	public Transform target;

	private Vector3 direction;

	private void Start()
	{
		direction = target.position - base.transform.position;
		direction = direction.normalized;
	}

	private void FixedUpdate()
	{
		rg2d.velocity = direction * moveSpeed * Time.fixedDeltaTime;
	}

	private void OnCollisionEnter2D(Collision2D coll)
	{
		if (coll.gameObject.layer.ToString() == "Player" || coll.gameObject.tag == "PLATFORM")
		{
			UnityEngine.Object.Destroy(rg2d);
			base.enabled = false;
			base.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 10f));
			base.transform.SetParent(coll.transform);
		}
	}
}
